<%-- 
    Document   : listnhomma
    Created on : Nov 8, 2011, 10:35:25 PM
    Author     : Venus
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<%@page import="java.util.*,Beans.ThamSoHT, Models.ThamSoHT_Model, Models.NhomMA_Model"%>
<script type="text/javascript">
    function keypress(e){
        //Hàm dùng để ngăn người dùng nhập các ký tự khác ký tự số vào TextBox
        var keypressed = null;
        if (window.event)
        {
            keypressed = window.event.keyCode; //IE
        }
        else
        {
            keypressed = e.which; //NON-IE, Standard
        }
        if (keypressed < 48 || keypressed > 57 )
        { //CharCode của 0 là 48 (Theo bảng mã ASCII)
            //CharCode của 9 là 57 (Theo bảng mã ASCII)
            if (keypressed == 8 || keypressed == 127  )
            {//Phím Delete và Phím Back
                return;
            }
            return false;
        }
    }
</script>
<%
            int langid = (Integer) session.getAttribute("langid"); // ngôn ngữ hiện tại
            String dsts = " 'all', 'notice', 'rightmsg', 'disable', 'enable',  'order', 'status',  'typefood', 'foodgroupsname', 'foodgrouplist' ";
            ThamSoHT[] mdsts = ThamSoHT_Model.DSThamSo(dsts, langid); // mảng chứa các tham số của trang này.

            String all = mdsts[0].getTenTS();
            String disable = mdsts[1].getTenTS();
            String enable = mdsts[2].getTenTS();            
            String foodgrouplist = mdsts[3].getTenTS();
            String foodgroupsname = mdsts[4].getTenTS();
            String notice = mdsts[5].getTenTS();
            String order = mdsts[6].getTenTS();
            String rightmsg = mdsts[7].getTenTS();
            String status = mdsts[8].getTenTS();
            String typefood = mdsts[9].getTenTS();
            
            String msgright = notice + "/" + rightmsg;
            Vector vDSNMA = (Vector) request.getAttribute("DSNMA");

            int numpage = 0;// khởi tạo số trang = 0
            int vsize = vDSNMA.size();
            if (vsize % 6 == 0) // mỗi trang có 6 dòng
            {
                numpage = vsize / 6;
            } else {
                numpage = vsize / 6 + 1;
            }
            String xx = (String) request.getAttribute("item"); // trang hiện tại đang xem
            int item = Integer.parseInt(xx);

%>
    <div class="title">
        <%=foodgrouplist%>
        
    </div>
    <div class="content">
        <form name="dsnhommonan" action="">
            <table class="mytable" border="0" cellpadding="0" cellspacing="0">
                <thead>
                    <tr>
                        <th style="width: 10%;  "><%=order%></th>
                        <th style=" width: 25%;">
                            <a href="#" id="titledskv1" style="margin-top: 5px;" class="down" lang="<%=msgright%>" name="1" onclick="SortTenLMA(this.className, this.name, this.lang)">
                                <div style="float:left"><%=typefood %></div>
                                <div id="sortkv1" style=" margin-right: 15px;" class="down1"></div>
                            </a>
                        </th>
                        <th style="width: 34%; ">
                            <a href="#" id="titledskv2" style="margin-top: 5px;" class="down" lang="<%=msgright%>" name="1" onclick="SortTenNMAA(this.className, this.name, this.lang)">
                                <div style="float:left"><%=foodgroupsname %></div>
                                <div id="sortkv2" style=" margin-right: 19px;" class="down1"></div>
                            </a>
                        </th>
                        <th style=" margin-top: 2px;">
                            <a href="#" id="titledskv3" class="down"  name="1" lang="<%=msgright%>" onclick="SortTTNMA(this.className, this.name, this.lang)">
                                <div><%=status%></div>
                                <div >
                                    <div id="sortkv3" class="down2"></div>
                                    <div id="sortkv3" class="up2" style="display:none;"></div>
                                </div>
                            </a>
                        </th>
                    </tr>
                    <tr id="searchNMA">
                        <th><img style=" margin-top: 2px; margin-left: 3px; margin-bottom: -7px; cursor: pointer;" alt="1" src="../images/search1.png" lang="<%=msgright%>" onclick="SearchNMA(this.alt, this.lang)"></th>
                        <th><input type="textbox" style=" width: 100px;" name="LOAITHUCAN" class="loaithucan text" ></th>
                        <th><input type="textbox" style=" width: 145px;" name="TENNHOMMONAN" class="tennhommonan text" ></th>
                        <th>
                            <div>
                                <select  class="select" id="1" name="TINHTRANG" lang="<%=msgright%>" onchange="SearchNMA(this.id, this.lang)">
                                    <option value="all"><%=all%></option>
                                    <option value="1"><%=enable%></option>
                                    <option value="0"><%=disable%></option>
                                </select>
                            </div>
                        </th>
                    </tr>
                </thead>
                <tbody>
                    <%
                        for (int i = (item - 1) * 6; i < (item - 1) * 6 + 6 && i < vsize; i++) {
                            Beans.NhomMA nma = (Beans.NhomMA) vDSNMA.elementAt(i);
                    %>
                    <tr>
                        <td class="STT"><%= i + 1%></td>
                        <td>
                            <select name="<%=nma.getMaNMA()%>" lang="<%=msgright%>" onchange="UpdateLMA(this.name, this.value, this.lang)">
                                <%
                                    if(nma.getMaLMA() == 1){%>
                                        <option value="1"><%=NhomMA_Model.LayTenLoaiMA(1, langid)  %></option>
                                        <option value="2"><%=NhomMA_Model.LayTenLoaiMA(2, langid)  %></option>
                                <%  }else{%>
                                        <option value="2"><%=NhomMA_Model.LayTenLoaiMA(2, langid)  %></option>
                                        <option value="1"><%=NhomMA_Model.LayTenLoaiMA(1, langid)  %></option>
                                <%  }%>
                            </select>
                        </td>
                        <td class="TenKV"><a href="#" name="<%=nma.getMaNMA()%>" lang="<%=msgright%>" onclick="ShowLangFG(this.name, this.lang)"><%=nma.getTenNMA()  %></a></td>
                        <td>
                            <select  class="<%= nma.getMaNMA() %>" lang="<%=msgright%>" onchange="UpdateStatusNMA(this.value,  this.className, this.lang)">
                                <%
                                    if (nma.getTinhTrang() == 1) {%>
                                        <option value="1"><%= enable%></option>
                                        <option value="0"><%= disable%></option>
                                <%  } else {%>
                                        <option value="0"><%= disable%></option>
                                        <option value="1"><%= enable%></option>
                                <%  }
                                %>
                            </select>
                        </td>
                    </tr>
                    <%  }
                    %>
                </tbody>
            </table>
                <div class="pagination">
                    <%
                                int trang = 1;
                                if (item > 1) {
                                    trang = item - 1;
                                }
                    %>
                    <%
                                if (vsize > 6) {%>
                    <a href="#" class="prev"  name="<%= trang%>" lang="<%=msgright%>" onclick="Foodgroups( this.name, this.lang)">«</a>
                    <%
                                                for (int c = 1; c <= numpage; c++) {

                                                    if (c != item) {
                    %> <a href="#"  name="<%= c%>" lang="<%=msgright%>" onclick="Foodgroups(this.name, this.lang)" ><%= c%></a>
                    <% } else {%><a class="current"> <%= c%></a> <% }

                                                }
                    %>
                    <%
                                                if (item + 1 <= numpage) {
                                                    trang = item + 1;
                                                } else {
                                                    trang = item;
                                                }
                    %>
                    <a href="#" class="next"  name="<%= trang%>" lang="<%=msgright%>" onclick="Foodgroups( this.name, this.lang)">»</a>

                    <%  }
                    %>
                </div>
        </form>
    </div>